package antTrail;

import GA.Algorithm;

public class Node {
	
	public enum tNode {AVANZA, DERECHA, IZQUIERDA,		// Terminals
		   			   SIC, PROGN2, PROGN3};			// Operators
	
	public tNode info;
	
	public int getNumberOfArgs() {
		switch (info){
		case SIC:
			return 2;
		case PROGN2:
			return 2;
		case PROGN3:
			return 3;
		}
		return -1;
	}

	public void randomOperator() {
		int r = Algorithm.random.nextInt(3);
		switch (r){
		case 0:
			info = tNode.SIC;
			break;
		case 1:
			info = tNode.PROGN2;
			break;
		case 2:
			info = tNode.PROGN3;
			break;
		}
	}

	public void randomTerminal() {
		int r = Algorithm.random.nextInt(3);
		switch (r){
		case 0:
			info = tNode.AVANZA;
			break;
		case 1:
			info = tNode.DERECHA;
			break;
		case 2:
			info = tNode.IZQUIERDA;
			break;
		}		
	}

	public boolean isTerminal() {
		if (info == tNode.AVANZA ||
			info == tNode.DERECHA ||
			info == tNode.IZQUIERDA)
			return true;
		else
			return false;
	}

	public boolean canMutate() {
		if (info == tNode.SIC ||
			info == tNode.PROGN2)
			return true;
		else
			return false;
	}

	public void mutate() {
		if (info == tNode.SIC)
			info = tNode.PROGN2;
		else if (info == tNode.PROGN2)
			info = tNode.SIC;		
	}

}
